package com.yang.auth.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yang.auth.model.entity.Permission;
import com.yang.auth.model.mapper.PermissionMapper;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class PermissionDao extends ServiceImpl<PermissionMapper, Permission> {


    /**
     * 查询app内所有可用的权限（核心字段，不查询多余字段）
     * @return
     */
    public List<Permission> selectAppAllEnablePermissionCoreField() {
        return baseMapper.selectList(
                new LambdaQueryWrapper<Permission>()
                        .select(Permission::getId, Permission::getName, Permission::getPermissionKey)   //  核心字段
                        .eq(Permission::getIsDeleted, false)        //  未被删除
                        .eq(Permission::getStatus, 0)               //  状态正常
                        .eq(Permission::getType, 3)                 //  按钮权限
        );
    }
}
